﻿Imports System.Data
Imports VSModel
Imports Cls_Common

Partial Class Control_MSDS_Section08View
    Inherits System.Web.UI.UserControl
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            hidMSDSID.Value = IIf(IsNothing(Request.QueryString("Id")), 0, CInt(Request.QueryString("Id")))
            ShowData()
        End If
    End Sub
    Protected Sub Translate()
        lblSection08Header.Text = getTranslate("lblSection08Header", Session("LanguageId"), lblSection08Header.Text)
        lblS811.Text = getTranslate("lblS811", Session("LanguageId"), lblS811.Text)
        lblS821.Text = getTranslate("lblS821", Session("LanguageId"), lblS821.Text)
        lblS831.Text = getTranslate("lblS831", Session("LanguageId"), lblS831.Text)
        lblS841.Text = getTranslate("lblS841", Session("LanguageId"), lblS841.Text)
    End Sub
    Protected Sub ShowData()
        Using data As New VSEntities
            'Tiêu đề doanh nghiệp
            Dim lang = CInt(Session("LanguageId"))
            Dim Id As Integer = hidMSDSID.Value
            Dim p As MSDSSection08 = (From a In data.MSDSSection08 Where a.MSDSId = Id And a.LanguageId = lang).SingleOrDefault
            If Not IsNothing(p) Then
                hidID.Value = p.Section08Id

                'Content
                lblViewS811.Text = IIf(IsNothing(p.S811) = True, "", p.S811)
                'lblViewS821.Text = IIf(IsNothing(p.S821) = True, "", p.S821)
                Dim strS821 = "<ul style='padding-left:20px'>"
                If Not IsNothing(p.S821) Then
                    Dim arrS821() As String = p.S821.Split(Str_Symbol_Group)
                    For index As Integer = 0 To arrS821.Count - 2
                        strS821 = strS821 + "<li>" + arrS821(index) & "</li>" & Environment.NewLine
                    Next
                    strS821 = strS821 + "<li>" + arrS821(arrS821.Count - 1) & "</li>"
                End If
                lblViewS821.Text = IIf(IsNothing(p.S821) = True, "", strS821 + "</ul>")
                lblViewS831.Text = IIf(IsNothing(p.S831) = True, "", p.S831)
                lblViewS841.Text = IIf(IsNothing(p.S841) = True, "", p.S841)
            End If
            'Label
            Translate()
        End Using
    End Sub
End Class
